#coding=utf-8
#主页panel
#time:20170906

import wx
#首页面板
class MainPanel(wx.Panel):
	def __init__(self, parent,id=-1,pos=wx.DefaultPosition, size=(-1, -1)):
		wx.Panel.__init__(self, parent,id, pos, size)
		self.SetBackgroundColour("#e7eced")
		self.parent = parent
		
		self.p1 = wx.Panel(self,-1,size=(480,245),pos=(10,10))
		self.p1.SetBackgroundColour('#ffffff')
		

		self.p2 = wx.Panel(self,-1,size=(480,245),pos=(490,10))
		self.p2.SetBackgroundColour('#ffffff')

		self.p3 = wx.Panel(self,-1,size=(480,245),pos=(10,255))
		self.p3.SetBackgroundColour('#ffffff')

		self.p4 = wx.Panel(self,-1,size=(480,245),pos=(490,255))
		self.p4.SetBackgroundColour('#ffffff')


		self.OnP1ShowView()
		self.OnP2ShowView()
		self.OnP3ShowView()
		self.OnP4ShowView()

		self.Bind(wx.EVT_SIZE,self.OnSetSize)


	#当大小变化时触发
	def OnSetSize(self,evt):
		if self.parent.IsIconized():
			return

		self.parentSize = self.parent.GetSize()
		self.width = self.parentSize[0]-160 
		self.height = self.parentSize[1]-120

		self.p1.SetSize(wx.Size(self.width/2,self.height/2))
		self.p2.SetSize(wx.Size(self.width/2,self.height/2))
		self.p3.SetSize(wx.Size(self.width/2,self.height/2))
		self.p4.SetSize(wx.Size(self.width/2,self.height/2))
		self.p1titleP.SetSize(wx.Size(self.width/2-4,30))
		self.p2titleP.SetSize(wx.Size(self.width/2-4,30))
		self.p3titleP.SetSize(wx.Size(self.width/2-4,30))
		self.p4titleP.SetSize(wx.Size(self.width/2-4,30))


		self.p1.SetPosition((10,10))
		self.p2.SetPosition((self.width/2+20,10))
		self.p3.SetPosition((10,self.height/2+20))
		self.p4.SetPosition((self.width/2+20,self.height/2+20))

		self.Refresh()

	def OnP1ShowView(self):
		self.parentSize = self.parent.GetSize()
		self.width = self.parentSize[0]-160 
		self.height = self.parentSize[1]-120
		self.p1titleP = wx.Panel(self.p1,-1,size=(self.width/2-4,30),pos=(2,2))
		self.p1titleP.SetBackgroundColour('#f5f6f8')
		titleText = wx.StaticText(self.p1titleP,-1,u'常用功能',pos=(40,5))

		#Titlepng图标
		b = wx.Image('images/main/ooopic_1504429486.png',wx.BITMAP_TYPE_PNG).Scale(32,32)
		wx.StaticBitmap(self.p1titleP,-1,wx.Bitmap(b),pos=(5,0))

		#入库单png 1
		rukupng = wx.Panel(self.p1,-1,pos=(15,40),size=(85,85))
		rukupng.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/add.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(rukupng,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(rukupng,-1,u'商品入库',pos=(20,65))

		#出库单png2
		chukupng = wx.Panel(self.p1,-1,pos=(105,40),size=(85,85))
		chukupng.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/remove.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(chukupng,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(chukupng,-1,u'商品出库',pos=(20,65))

		#收款单png3
		shoukuandanpng = wx.Panel(self.p1,-1,pos=(195,40),size=(85,85))
		shoukuandanpng.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/page_full.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(shoukuandanpng,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(shoukuandanpng,-1,u'收款单',pos=(20,65))

		#付款单png4
		fukuandan = wx.Panel(self.p1,-1,pos=(285,40),size=(85,85))
		fukuandan.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/page.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(fukuandan,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(fukuandan,-1,u'付款单',pos=(20,65))

		#计算机png5
		jisuanji = wx.Panel(self.p1,-1,pos=(375,40),size=(85,85))
		jisuanji.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/calculator.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(jisuanji,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(jisuanji,-1,u'计算器',pos=(20,65))

		#库存管理png6
		kucun = wx.Panel(self.p1,-1,pos=(15,135),size=(85,85))
		kucun.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/windows.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(kucun,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(kucun,-1,u'库存管理',pos=(20,65))

		#供应商png7
		gongyingshang = wx.Panel(self.p1,-1,pos=(105,135),size=(85,85))
		gongyingshang.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/gongyingshang.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(gongyingshang,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(gongyingshang,-1,u'供应商管理',pos=(20,65))

		#商品管理png8
		shangpinguanli = wx.Panel(self.p1,-1,pos=(195,135),size=(85,85))
		shangpinguanli.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/save.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(shangpinguanli,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(shangpinguanli,-1,u'商品管理',pos=(20,65))

		#记事本png9
		notepad = wx.Panel(self.p1,-1,pos=(285,135),size=(85,85))
		notepad.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/book.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(notepad,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(notepad,-1,u'记事本',pos=(20,65))

		#意见反馈png9
		yijian = wx.Panel(self.p1,-1,pos=(375,135),size=(85,85))
		yijian.SetBackgroundColour('#fefefe')
		b = wx.Image('images/main/mail.png',wx.BITMAP_TYPE_PNG).Scale(64,64)
		wx.StaticBitmap(yijian,-1,wx.Bitmap(b),pos=(15,5))
		wx.StaticText(yijian,-1,u'意见反馈',pos=(20,65))


	def OnP2ShowView(self):
		self.parentSize = self.parent.GetSize()
		self.width = self.parentSize[0]-160 
		self.height = self.parentSize[1]-120
		self.p2titleP = wx.Panel(self.p2,-1,size=(self.width/2-4,30),pos=(2,2))
		self.p2titleP.SetBackgroundColour('#f5f6f8')
		titleText = wx.StaticText(self.p2titleP,-1,u'经营数据',pos=(40,5))

		#Titlepng图标
		b = wx.Image('images/main/ooopic_1504429503.png',wx.BITMAP_TYPE_PNG).Scale(32,32)
		wx.StaticBitmap(self.p2titleP,-1,wx.Bitmap(b),pos=(5,0))

		#收入毛利
		self.crpriceP = wx.Panel(self.p2,-1,pos=(15,50),size=(410,60))
		self.crpriceP.SetBackgroundColour('#f5f6f8')
		self.crpricePL = wx.Panel(self.crpriceP,-1,pos=(0,0),size=(5,60))
		self.crpricePL.SetBackgroundColour('#76c2af')
		self.shouru = wx.StaticText(self.crpriceP,-1,u'0.00',pos=(20,5))
		self.shouru.SetFont(wx.Font(20,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		self.shouru.SetForegroundColour('#67737c')
		wx.StaticText(self.crpriceP,-1,u'收入(本月)',pos=(20,35)).SetForegroundColour('#67737c')

		self.maoli = wx.StaticText(self.crpriceP,-1,u'0.00',pos=(220,5))
		self.maoli.SetFont(wx.Font(20,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		self.maoli.SetForegroundColour('#67737c')
		wx.StaticText(self.crpriceP,-1,u'毛利(本月)',pos=(220,35)).SetForegroundColour('#67737c')


		#库存总量成本
		self.crchengbenP = wx.Panel(self.p2,-1,pos=(15,140),size=(200,60))
		self.crchengbenP.SetBackgroundColour('#f5f6f8')
		self.crchengbenPL = wx.Panel(self.crchengbenP,-1,pos=(0,0),size=(5,60))
		self.crchengbenPL.SetBackgroundColour('#e0995e')
		wx.StaticText(self.crchengbenP,-1,u'库存总量',pos=(20,10)).SetForegroundColour('#67737c')
		wx.StaticText(self.crchengbenP,-1,u'库存成本',pos=(20,35)).SetForegroundColour('#67737c')
		self.zongliang = wx.StaticText(self.crchengbenP,-1,u'0.00',pos=(150,10))
		self.zongliang.SetForegroundColour('#67737c')
		self.chengben = wx.StaticText(self.crchengbenP,-1,u'0.00',pos=(150,35))
		self.chengben.SetForegroundColour('#67737c')


		#欠款
		self.crqiankuanP = wx.Panel(self.p2,-1,pos=(225,140),size=(200,60))
		self.crqiankuanP.SetBackgroundColour('#f5f6f8')
		self.crqiankuanPL = wx.Panel(self.crqiankuanP,-1,pos=(0,0),size=(5,60))
		self.crqiankuanPL.SetBackgroundColour('#029be2')
		wx.StaticText(self.crqiankuanP,-1,u'客户欠款',pos=(20,10)).SetForegroundColour('#67737c')
		wx.StaticText(self.crqiankuanP,-1,u'供应商欠款',pos=(20,35)).SetForegroundColour('#67737c')
		self.kehuqiankuan = wx.StaticText(self.crqiankuanP,-1,u'0.00',pos=(150,10))
		self.kehuqiankuan.SetForegroundColour('#67737c')
		self.gongyingshangqiankuan = wx.StaticText(self.crqiankuanP,-1,u'0.00',pos=(150,35))
		self.gongyingshangqiankuan.SetForegroundColour('#67737c')

	def OnP3ShowView(self):
		self.parentSize = self.parent.GetSize()
		self.width = self.parentSize[0]-160 
		self.height = self.parentSize[1]-120
		self.p3titleP = wx.Panel(self.p3,-1,size=(self.width/2-4,30),pos=(2,2))
		self.p3titleP.SetBackgroundColour('#f5f6f8')
		titleText = wx.StaticText(self.p3titleP,-1,u'待办事项',pos=(40,5))

		#Titlepng图标
		b = wx.Image('images/main/ooopic_1504429524.png',wx.BITMAP_TYPE_PNG).Scale(32,32)
		wx.StaticBitmap(self.p3titleP,-1,wx.Bitmap(b),pos=(5,0))

		self.daibannullpl = wx.Panel(self.p3,-1,pos=(50,50),size=(350,170))
		self.daibannullpl.SetBackgroundColour('#fafafa')
		b = wx.Image('images/main/g22.png',wx.BITMAP_TYPE_PNG).Scale(128,128)
		wx.StaticBitmap(self.daibannullpl,-1,wx.Bitmap(b),pos=(30,10))
		daibantext = wx.StaticText(self.daibannullpl,-1,u'暂未设定',pos=(170,60))
		daibanshixiangText = wx.StaticText(self.daibannullpl,-1,u'待办事项',pos=(170,90))
		daibantext.SetFont(wx.Font(20,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		daibantext.SetForegroundColour('#67737c')
		daibanshixiangText.SetFont(wx.Font(20,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		daibanshixiangText.SetForegroundColour('#67737c')

	def OnP4ShowView(self):
		self.parentSize = self.parent.GetSize()
		self.width = self.parentSize[0]-160 
		self.height = self.parentSize[1]-120
		self.p4titleP = wx.Panel(self.p4,-1,size=(self.width/2-4,30),pos=(2,2))
		self.p4titleP.SetBackgroundColour('#f5f6f8')
		titleText = wx.StaticText(self.p4titleP,-1,u'信息消息',pos=(40,5))

		#Titlepng图标
		b = wx.Image('images/main/ooopic_1504430612.png',wx.BITMAP_TYPE_PNG).Scale(32,32)
		wx.StaticBitmap(self.p4titleP,-1,wx.Bitmap(b),pos=(5,0))

		wx.StaticText(self.p4,-1,u'2017-09-04:网络已连接，当前版本：[免费版]',pos=(20,60)).SetFont(wx.Font(12,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		wx.StaticText(self.p4,-1,u'2017-09-04:系统初始化成功',pos=(20,90)).SetFont(wx.Font(12,wx.DEFAULT, wx.NORMAL, wx.BOLD))
